#pragma once

#include <unordered_map>
#include "../share/user_define.h"
#include "../../3rd/libjson/json.h"


class BuyResetData
{
public:
	uint32_t mId;
	uint32_t mFinishReward;
	std::vector<uint32_t> mBuyReward;

public:
	BuyResetData()
	{
		Clear();
	}

	void Clear(void)
	{
		mId = 0;
		mFinishReward = 0;
		mBuyReward.clear();
	}

	uint32_t GetCostValueByIndex(uint32_t idx)
	{
		if (idx >= mBuyReward.size())
		{
			idx = mBuyReward.size() - 1;
		}

		return mBuyReward[idx];
	}
};

class BuyResetCnfgTable
{
public:
	BuyResetCnfgTable();
	~BuyResetCnfgTable();

public:
	BuyResetData* GetBuyResetDataById(uint32_t id);

	uint32_t GetBuyResetDataCount(void);

	BuyResetData*  GetBuyResetDataByIdx(uint32_t idx);

private:
	bool addToIndex(int32_t id, uint32_t idx);

	void addData(uint32_t id, Json::Value& jm);

private:
	std::vector<BuyResetData*> m_content;
	std::unordered_map<uint32_t, int32_t> m_index;
	uint32_t m_max_count;
};